<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/static/common/default.jsp"%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css">
.advance_tip_pwd {
	background-color: #fff;
	left: 42%;
	position: fixed;
	top: 200px;
	width: 487px;
	z-index: 5;
}
</style>
</head>
<body>
	<div class="cinema_tip">
		<div class="cinema_subject clearfix">
			<div class="cinema_title">
				<a href="#">项目管理</a> > <a href="#" class="cinema_option">项目信息</a>
			</div>
		</div>
		<form id="sysProInfoSearchForm" method="get"
			action="${ctx }/sys/sysProjectMan/ProjectInfo/toSearch">
			<div class="cinema_search clearfix">
				<!-- <label class="col-sm-1 control-label no-padding-right" for="form-field-1"> 用户名： </label> -->
				<div class="cinema_condition width_84">
					<div class="cinema_smart">
						<div class="cinema_inter">
							<input type="text" id="proCode" name="proCode" maxlength="50"
								placeholder="请输入项目编号" class="col-xs-10 col-sm-2" />
						</div>
					</div>
				</div>

				<div class="cinema_button">
					<input id="sysProInfoSearch" type="submit" value="查询"
						style="float: none;" class="cinema_inquiry movie_no">
				</div>
			</div>

		</form>
	</div>
	<div class="cinema_list">
		<div class="movie_button">
			<a class="movie_new"
				href="${ctx}/sys/sysProjectMan/ProjectInfo/toAdd"
				style="background-color: rgb(75, 208, 131); color: rgb(255, 255, 255);">新建</a>
			<div class="column_content">
				<div class="column_content1">
					<table id="sysProInfoDatas" width="100%" height="" border="0"
						cellpadding="0" cellspacing="1" class="border_top">
						<tr style="background-color: rgb(243, 247, 255);">
							<th nowrap="" style="padding:0px 5px;">项目编号</th>
							<th nowrap="" style="padding:0px 5px;">项目名称</th>
							<th nowrap="" style="padding:0px 5px;">项目区域</th>
							<th nowrap="" style="padding:0px 5px;">项目经理</th>
							<th nowrap="" style="padding:0px 5px;">物资部负责人</th>
							<th nowrap="" style="padding:0px 5px;">合同部负责人</th>
							<th nowrap="" style="padding:0px 5px;">状态</th>
							<th nowrap="" style="padding:0px 5px;">操作</th>
						</tr>
						<c:forEach var="res" items="${res.data.rows}">
							<tr class="odd" style="background-color: rgb(255, 255, 255);"
								id="userinfo_row_${res.proId}">
								<td nowrap="" style="padding:0px 5px;" title="${res.proCode}">&nbsp;${res.proCode}</td>
								<td nowrap="" style="padding:0px 5px;" title="${res.name}">&nbsp;${res.name}</td>
								<td nowrap="" style="padding:0px 5px;" title="${res.district}">&nbsp;${res.district}</td>
								<td nowrap="" style="padding:0px 5px;" title="${res.manager}">&nbsp;${res.manager}</td>
								<td nowrap="" style="padding:0px 5px;">&nbsp;${res.wzbUserName}</td>
								<td nowrap="" style="padding:0px 5px;">&nbsp;${res.htbUserName}</td>
								<td nowrap="" style="padding:0px 5px;" title="${res.status}">&nbsp;
									<c:choose>
										<c:when test="${res.status==1}">未开工</c:when>
										<c:when test="${res.status==2}">已开工</c:when>
										<c:when test="${res.status==3}">已完工</c:when>
									</c:choose>
								</td>

								<td nowrap="" style="padding:0px 5px;width:150px">
									<a style="margin-left: 3%;" href="${ctx}/sys/sysProjectMan/ProjectInfo/toModify/${res.proId}" title="编辑项目">编辑</a>
								 
									<c:if test="${sessionScope.loginUser.roleId eq '1' }">
										<a style="margin-left: 3%;" href="${ctx}/sys/sysProjectMan/ProjectInfo/delete/${res.proId}" title="删除项目">删除</a>
									</c:if>
							    	
							    </td>	
							</tr>
						</c:forEach>
					</table>
				</div>
			</div>
			<!-- /.row -->
			<div id="manager_page" class="manager_page clearfix">
				<!-- 分页跳转 -->
				<div class="manager_show">
					<p>
						<span>跳转至</span><input id="pagenum" type="text" name=""
							value="${res.data.page}" />
					</p>
					<span id="toPage" class="manager_true"></span>
				</div>
				<!-- 分页数字导航栏 -->
				<div id="manager_number" class="manager_number"></div>
				<input type="hidden" id=records value="${res.data.records}" />
				<!-- 总记录数 -->
				<input type="hidden" id="pageSize" value="${res.data.pageSize}" />
				<!-- 每页个数 -->
				<input type="hidden" id="pageCurrent" value="${res.data.page}" />
				<!-- 当前页page -->
				<input type="hidden" id="totalPage" value="${res.data.total}" />
				<!-- 总页数 -->
			</div>
		</div>
		<!--提示弹框-->
		<script type="text/javascript">
			$("#modal_close").on("click", function() {
				$("#up_pwd_userName").text("");
				$("#up_pwd_userId").val("");
				$("#userpassword").val("");
				$("#re_userpassword").val("");
				$(".movie_shade").addClass("hidden");
				$(".advance_tip_pwd").addClass("hidden");
				return false;
			});
			function updatePWD(userName, id) {
				//显示删除提示框
				$(".movie_shade").removeClass("hidden");
				$(".advance_tip_pwd").removeClass("hidden");
				//动态更改用户名
				$("#up_pwd_userName").text(userName);
				//动态更改用户ID
				$("#up_pwd_userId").val(id);
			}

			$("#userpassword").on(
					"blur",
					function() {
						var userpassword = $("#userpassword").val();
						if (userpassword == undefined || userpassword == "") {
							$("#userpassword").css("border", "1px solid red");
						} else {
							$("#userpassword").css("border",
									"1px solid #dfe7f0");
						}
						var re_userpassword = $("#re_userpassword").val();
						if (re_userpassword != undefined
								&& re_userpassword != "") {
							if (userpassword != re_userpassword) {
								$("#re_userpassword").css("border",
										"1px solid red");
							} else {
								$("#re_userpassword").css("border",
										"1px solid #dfe7f0");
							}
						}
						return;
					});

			$("#re_userpassword").on(
					"blur",
					function() {
						var re_userpassword = $("#re_userpassword").val();
						if (re_userpassword == undefined
								|| re_userpassword == "") {
							$("#re_userpassword")
									.css("border", "1px solid red");
							return;
						} else {
							$("#re_userpassword").css("border",
									"1px solid #dfe7f0");
						}
						var userpassword = $("#userpassword").val();
						if (userpassword != undefined && userpassword != "") {
							if (userpassword != re_userpassword) {
								$("#re_userpassword").css("border",
										"1px solid red");
							} else {
								$("#re_userpassword").css("border",
										"1px solid #dfe7f0");
							}
						}
						return;
					});

			//点击确认执行更改操作
			$("#changePWD_sub").on(
					"click",
					function() {
						var userpassword = $("#userpassword").val();
						if (userpassword == undefined || userpassword == "") {
							alert("请输入密码。");
							return false;
						}
						var re_userpassword = $("#re_userpassword").val();
						if (re_userpassword == undefined
								|| re_userpassword == "") {
							alert("请输入确认密码。");
							return false;
						}
						if (re_userpassword != userpassword) {
							alert("两次输入密码不一致。");
							return false;
						}
						var userId = $("#up_pwd_userId").val();
						if (userId == undefined || userId == "") {
							alert("未知的错误发生了。");
							return false;
						}
						//更改密码请求提交
						$.ajax({
							type : "POST",
							dataType : "json",
							async : false,
							url : '${ctx}/sysUserInfo/password',
							data : {
								userId : userId,
								password : userpassword,
								password2 : re_userpassword
							},
							success : function(data) {
								if (data != undefined
										&& data.status != undefined
										&& data.status.trim() == '0') {
									alert("保存密码成功！");
									$("#modal_close").click();
								} else {
									alert(data.error);
								}
							},
							error : function(data) {
								alert(data.data);
							}
						});
						return false;
					});
			//用户基本信息删除
			function userDel(rowId) {
				if (rowId == undefined || (rowId + "").trim() == ""
						|| rowId <= 0) {
					alert("请选择需要修改记录！");
					return false;
				}
				if (confirm("确认删除该条用户信息？")) {
					deleteRowById(rowId);
				}
			}

			//删除用户ajax请求
			function deleteRowById(rowId) {
				$.ajax({
					type : "DELETE",
					dataType : "json",
					async : false,
					url : '${ctx}/sysUserInfo/delete/' + rowId,
					success : function(data) {
						if (data != undefined && data.status != undefined
								&& data.status.trim() == "0") {
							//$("#userinfo_row_"+rowId).remove();
							//将状态栏置为未启用状态
							//$("#userinfo_row_"+rowId).find(".column_status").text(" 未启用");
							//$($("#userinfo_row_"+rowId).find(".column_status")[0]).attr("title","未启用");
							//删除‘LDAP管理’及‘删除用户’两个操作功能
							//$("#userinfo_row_"+rowId).find(".LDAPManager").remove();
							//$("#userinfo_row_"+rowId).find(".user_delete").remove();
							$("#userinfo_row_" + rowId).remove();
							alert("删除成功。");
						} else {
							alert("error:" + data.error);
						}
					},
					error : function(data) {
						alert("删除失败。");
					}
				});
				return false;
			}

			//项目基本信息删除
			function proDel(rowId) {
				if (rowId == undefined || (rowId + "").trim() == ""
						|| rowId <= 0) {
					alert("请选择需要删除记录！");
					return false;
				}
				if (confirm("确认删除该条用户信息？")) {
					deleteRowById(rowId);
				}
			}

			//删除项目ajax请求
			function deleteRowById(rowId) {
				$.ajax({
					type : "DELETE",
					dataType : "json",
					async : false,
					url : '${ctx}/sys/sysProjectMan/ProjectInfo/delete/'
							+ rowId,
					success : function(data) {
						if (data != undefined && data.status != undefined
								&& data.status.trim() == "0") {
							$("#userinfo_row_" + rowId).remove();
							alert("删除成功。");
						} else {
							alert("error:" + data.error);
						}
					},
					error : function(data) {
						alert("删除失败。");
					}
				});
				return false;
			}
		</script>
</body>
</html>
